package com.zhainan.springmvc.handler;


import com.zhainan.springmvc.annotation.RequestMapping;
import com.zhainan.springmvc.annotation.RequestParam;
import com.zhainan.springmvc.view.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by lvchang on 2016/10/2.
 */
public class DemoHandler {

    @RequestMapping(value = "/test")
    public void test(HttpServletRequest request,
                     HttpServletResponse response) throws IOException {

        response.getWriter().write("<h1>test</h1>");
    }

    @RequestMapping(value = "/demo")
    public ModelAndView demo(@RequestParam(value = "name") String name,
                         @RequestParam(value = "age") String age) {

        Map<String, String> model = new HashMap<String, String>();
        model.put("name", name);
        model.put("age", age);

        return new ModelAndView(model, "my.view");
    }

}
